const { db, query } = require("../../db/db");
const util = require("util");
const moment = require("moment");

async function GetSentence(req, res) {
  const Date = req.body.Date;

  const Select_sentence = util.format(
    "SELECT * \
  FROM Sign_Famous_Quote \
  ORDER BY RAND('%s')\
  LIMIT 1",
    Date
  );

  const Select_sentence_res = await query(Select_sentence);

  if (Select_sentence_res[0]) {
    res.send({
      status: 0,
      FquoteTitle: Select_sentence_res[0].FquoteTitle,
      FquoteSentence: Select_sentence_res[0].FquoteSentence,
    });
  } else {
    res.send({
      status: 0,
      FquoteTitle: "请补充内容",
      FquoteSentence: "请补充内容",
    });
  }
}

module.exports = { GetSentence };
